<template>
  <div class="tab-box">
    <div class="tab-icon" :style="`background: ${color};`">
      <ali-icon
        :icon="icon"
        v-if="icon"
        color="white"
        :size="20"
      />
    </div>
    <div class="tab-text">
      <div class="title">{{ title }}</div>
      <div class="desc">
        <i-count-up
          :delay="0"
          :endVal="description"
          :options="options"
          @ready="onReady"
        />
        万+
      </div>
    </div>
  </div>
</template>

<script>
import AliIcon from "@/components/aliIcon/index"
import ICountUp from "vue-countup-v2";

export default {
  name: 'ClueTab',
  components: {
    AliIcon,
    ICountUp
  },
  data() {
    return {
      options: {
        useEasing: true,
        useGrouping: true,
        separator: ",",
        decimal: ".",
        prefix: "",
        suffix: ""
      }
    }
  },
  props: {
    icon: {
      type: String,
      default() {
        return 'iconzhuanlixinxi'
      }
    },
    color: {
      type: String,
      default() {
        return '#DC4646'
      }
    },
    title: {
      type: String,
      default() {
        return '企业专利数'
      }
    },
    description: {
      type: Number,
      default() {
        return '7000万+'
      }
    }
  },
  methods: {
    onReady: function(instance, CountUp) {
      const that = this;
      instance.update(that.description);
    }
  }
}
</script>

<style lang="scss" scoped>
.tab-box  {
  display: flex;
  justify-content: flex-start;
  height: 80px;
  min-width: 300px;
  min-height: 150px;
  padding: 38px;
  .tab-icon {
    height: 72px;
    width: 72px;
    border-radius: 50%;
    padding: 16px;
    margin-right: 18px;
    .icon {
      width: 100%;
      height: 100%;
    }
  }
  .tab-text {
    height: 72px;
    width: 120px;
    padding: 5px;
    .title {
      color: #909399;
      font-size: 18px;
      font-weight: 400;
      line-height: 30px;
    }
    .desc {
      color: #303133;
      font-size: 1rem;
      font-weight: 400;
      line-height: 30px;
    }
  }
}
</style>
